package cn.kgc.shiro.handler;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 课工场
 * @date 2023/11/22
 * @description
 */
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(AuthorizationException.class)
    public Map<String,Object> authorizationExceptionHandler(AuthorizationException e){

        HashMap<String, Object> map = new HashMap<>();
        map.put("code", 403);
        map.put("message", "没有权限，请联系管理员");

        return  map;
    }
}
